<template>
  <div class="desktop-intro" :class="{ 'fade-out': isClosing }" v-if="visible">
    <!-- 背景层 -->
    <div class="background-layer">
      <!-- 动态网格背景 -->
      <div class="grid-background">
        <div v-for="i in 100" :key="i" class="grid-dot" :style="getGridDotStyle(i)"></div>
      </div>
      
      <!-- 流动的线条 -->
      <div class="flowing-lines">
        <div v-for="i in 8" :key="i" class="flow-line" :style="getFlowLineStyle(i)"></div>
      </div>
      
      <!-- 渐变背景 -->
      <div class="gradient-overlay"></div>
    </div>

    <!-- 主要内容 -->
    <div class="intro-content">
      <!-- Logo区域 -->
      <div class="logo-section" :class="{ 'animate': showContent }">
        <div class="logo-container">
          <div class="logo-icon">
            <!-- 旋转的装饰环 -->
            <div class="orbit-ring ring-1">
              <div class="orbit-dot dot-1"></div>
              <div class="orbit-dot dot-2"></div>
            </div>
            <div class="orbit-ring ring-2">
              <div class="orbit-dot dot-3"></div>
              <div class="orbit-dot dot-4"></div>
            </div>
            
            <!-- 中心图标 -->
            <div class="center-icon">
              <svg width="60" height="60" viewBox="0 0 24 24" fill="currentColor">
                <path d="M12,2C8.13,2 5,5.13 5,9C5,14.25 12,22 12,22C12,22 19,14.25 19,9C19,5.13 15.87,2 12,2M12,11.5A2.5,2.5 0 0,1 9.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,11.5Z"/>
              </svg>
            </div>
          </div>
        </div>
        
        <h1 class="main-title">
          <span class="title-line title-line-1">
            <span class="word" v-for="(word, index) in '廉洁文化'.split('')" :key="index" :style="{ animationDelay: (index * 0.1) + 's' }">
              {{ word }}
            </span>
          </span>
          <span class="title-line title-line-2">
            <span class="word" v-for="(word, index) in '地图系统'.split('')" :key="index" :style="{ animationDelay: (index * 0.1 + 0.5) + 's' }">
              {{ word }}
            </span>
          </span>
        </h1>
        
        <p class="subtitle" :class="{ 'animate': showSubtitle }">
          探索廉洁文化，感受历史传承
        </p>
      </div>

      <!-- 特性展示 -->
      <div class="features-section" :class="{ 'animate': showFeatures }">
        <div class="feature-card" v-for="(feature, index) in features" :key="index" :style="{ animationDelay: (index * 0.2) + 's' }">
          <div class="feature-icon">{{ feature.icon }}</div>
          <div class="feature-text">{{ feature.text }}</div>
        </div>
      </div>

      <!-- 开始按钮 -->
      <div class="start-section" :class="{ 'animate': showStartButton }">
        <button class="start-button" @click="startExperience">
          <span class="button-text">开始探索</span>
          <div class="button-effect"></div>
          <div class="button-ripple"></div>
        </button>
      </div>
    </div>

    <!-- 跳过按钮 -->
    <button class="skip-button" @click="skipIntro" :class="{ 'animate': showContent }">
      跳过介绍
    </button>

    <!-- 进度指示器 -->
    <div class="progress-indicator" :class="{ 'animate': showContent }">
      <div class="progress-bar" :style="{ width: progressWidth + '%' }"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DesktopIntro',
  data() {
    return {
      visible: true,
      isClosing: false,
      showContent: false,
      showSubtitle: false,
      showFeatures: false,
      showStartButton: false,
      progressWidth: 0,
      features: [
        { icon: '🗺️', text: '交互式地图' },
        { icon: '📍', text: '精准定位' },
        { icon: '🎯', text: '智能导览' },
        { icon: '📱', text: '多端适配' }
      ]
    }
  },
  mounted() {
    this.startIntroSequence()
  },
  methods: {
    startIntroSequence() {
      // 内容逐步显示
      setTimeout(() => {
        this.showContent = true
        this.updateProgress(20)
      }, 500)
      
      setTimeout(() => {
        this.showSubtitle = true
        this.updateProgress(40)
      }, 1200)
      
      setTimeout(() => {
        this.showFeatures = true
        this.updateProgress(70)
      }, 1800)
      
      setTimeout(() => {
        this.showStartButton = true
        this.updateProgress(100)
      }, 2500)
    },

    updateProgress(width) {
      this.progressWidth = width
    },

    startExperience() {
      this.closeIntro()
    },

    skipIntro() {
      this.closeIntro()
    },

    closeIntro() {
      this.isClosing = true
      setTimeout(() => {
        this.visible = false
        this.$emit('close')
      }, 800)
    },

    getGridDotStyle(index) {
      const row = Math.floor((index - 1) / 10)
      const col = (index - 1) % 10
      const delay = (row + col) * 0.1
      
      return {
        left: `${col * 10 + 5}%`,
        top: `${row * 10 + 5}%`,
        animationDelay: `${delay}s`
      }
    },

    getFlowLineStyle(index) {
      const angle = (index * 45) % 360
      const delay = index * 0.5
      
      return {
        transform: `rotate(${angle}deg)`,
        animationDelay: `${delay}s`
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.desktop-intro {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  overflow: hidden;
  animation: introFadeIn 1s ease-out;

  &.fade-out {
    animation: introFadeOut 0.8s ease-in forwards;
  }
}

// 背景层
.background-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, 
    #667eea 0%, 
    #764ba2 25%, 
    #f093fb 50%, 
    #f5576c 75%, 
    #4facfe 100%
  );
  background-size: 400% 400%;
  animation: gradientShift 8s ease-in-out infinite;
}

.gradient-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, 
    rgba(0, 0, 0, 0.1) 0%, 
    rgba(255, 255, 255, 0.1) 50%, 
    rgba(0, 0, 0, 0.1) 100%
  );
}

// 网格背景
.grid-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.3;
}

.grid-dot {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  animation: gridPulse 3s ease-in-out infinite;
}

// 流动线条
.flowing-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.2;
}

.flow-line {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  transform-origin: center;
  animation: flowMove 4s linear infinite;
}

// 主要内容
.intro-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  z-index: 10;
}

// Logo区域
.logo-section {
  text-align: center;
  margin-bottom: 60px;
  opacity: 0;
  transform: translateY(50px) scale(0.8);
  transition: all 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  
  &.animate {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.logo-container {
  position: relative;
  display: inline-block;
  margin-bottom: 40px;
}

.logo-icon {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
}

// 轨道环
.orbit-ring {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  
  &.ring-1 {
    width: 100px;
    height: 100px;
    animation: orbitRotate 8s linear infinite;
  }
  
  &.ring-2 {
    width: 140px;
    height: 140px;
    animation: orbitRotate 12s linear infinite reverse;
  }
}

.orbit-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  
  &.dot-1 {
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
  }
  
  &.dot-2 {
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
  }
  
  &.dot-3 {
    top: 50%;
    right: -4px;
    transform: translateY(-50%);
  }
  
  &.dot-4 {
    top: 50%;
    left: -4px;
    transform: translateY(-50%);
  }
}

.center-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: iconFloat 3s ease-in-out infinite;
}

// 标题
.main-title {
  margin: 0 0 20px 0;
  
  .title-line {
    display: block;
    
    .word {
      display: inline-block;
      font-size: 48px;
      font-weight: 900;
      color: white;
      text-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(255, 255, 255, 0.5);
      opacity: 0;
      transform: translateY(30px) rotateX(90deg);
      animation: wordDrop 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    }
  }
}

.subtitle {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.8s ease-out;
  
  &.animate {
    opacity: 1;
    transform: translateY(0);
  }
}

// 特性展示
.features-section {
  display: flex;
  gap: 30px;
  margin-bottom: 50px;
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s ease-out;
  
  &.animate {
    opacity: 1;
    transform: translateY(0);
  }
}

.feature-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  min-width: 120px;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  animation: featureSlideIn 0.6s ease-out forwards;
  
  .feature-icon {
    font-size: 32px;
    margin-bottom: 8px;
  }
  
  .feature-text {
    color: white;
    font-size: 14px;
    font-weight: 600;
  }
}

// 开始按钮
.start-section {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.8s ease-out;
  
  &.animate {
    opacity: 1;
    transform: translateY(0);
  }
}

.start-button {
  position: relative;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 18px 40px;
  border-radius: 50px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
  
  &:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
    
    .button-effect {
      opacity: 1;
    }
  }
  
  .button-text {
    position: relative;
    z-index: 2;
  }
  
  .button-effect {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    opacity: 0;
    transition: all 0.6s ease;
  }
  
  &:hover .button-effect {
    left: 100%;
  }
}

// 跳过按钮
.skip-button {
  position: absolute;
  top: 30px;
  right: 30px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: all 0.3s ease;
  
  &.animate {
    opacity: 1;
  }
  
  &:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
  }
}

// 进度指示器
.progress-indicator {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
  opacity: 0;
  transition: all 0.3s ease;
  
  &.animate {
    opacity: 1;
  }
  
  .progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
    transition: width 0.8s ease;
  }
}

// 动画定义
@keyframes introFadeIn {
  from {
    opacity: 0;
    transform: scale(1.1);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes introFadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

@keyframes gradientShift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes gridPulse {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.5);
  }
}

@keyframes flowMove {
  0% {
    transform: translateX(-200px) rotate(var(--rotation, 0deg));
  }
  100% {
    transform: translateX(200px) rotate(var(--rotation, 0deg));
  }
}

@keyframes orbitRotate {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes iconFloat {
  0%, 100% {
    transform: translate(-50%, -50%) translateY(0);
  }
  50% {
    transform: translate(-50%, -50%) translateY(-10px);
  }
}

@keyframes wordDrop {
  from {
    opacity: 0;
    transform: translateY(30px) rotateX(90deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0deg);
  }
}

@keyframes featureSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

// 响应式设计
@media (max-width: 1200px) {
  .main-title .title-line .word {
    font-size: 36px;
  }
  
  .features-section {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .feature-card {
    min-width: 100px;
  }
}

@media (max-width: 768px) {
  .intro-content {
    padding: 20px;
  }
  
  .main-title .title-line .word {
    font-size: 28px;
  }
  
  .subtitle {
    font-size: 16px;
  }
  
  .features-section {
    gap: 15px;
  }
  
  .feature-card {
    padding: 15px;
    min-width: 80px;
    
    .feature-icon {
      font-size: 24px;
    }
    
    .feature-text {
      font-size: 12px;
    }
  }
}
</style>
